using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService.Symbols;

/// <summary>
///     元数据循环字段下，fields关键字开始的子字段列表，此符号允许带有
///     自己的标签、属性、模板和样式。此符号的名称固定为"@class"
/// </summary>
public class MetadataClassSymbol : MetadataLabeledObjectSymbol
{
    internal readonly DomainSymbolTable Fields;

    public MetadataClassSymbol(MetadataFieldSymbol containingField, MetadataClass declaration) :
        base(SymbolKinds.MetadataClass, containingField, declaration)
    {
        LocationMap.AddLocation(declaration.GetLocation());
        Fields = new DomainSymbolTable(this);
    }

    public override string Name => "@class";


    public bool DeclareField(MetadataFieldSymbol field)
    {
        return Fields.DeclareSymbol(field);
    }

    public MetadataFieldSymbol? LookupField(string name, bool searchParent)
    {
        return Fields.LookupLocalSymbol(name, searchParent) as MetadataFieldSymbol;
    }
}